package Users;

public class UserInterface {
	private String userDomain, userName, userSurname, lastLoginDate, statsResetLink, userFilesTable;
    
	public void setUserDomain(String userDomain) {
		this.userDomain = userDomain;
	}

	public void setUserName(String userName) {
		this.userName = userName;
	}

	public void setUserSurname(String userSurname) {
		this.userSurname = userSurname;
	}

	public void setLastLoginDate(String lastLoginDate) {
		this.lastLoginDate = lastLoginDate;
	}

	public void setStatsResetLink(String link) {
		//this.statsResetLink = "<a href='"+link+"'>Reset statistic</a>";
		this.statsResetLink = "<input type=\"button\" onclick=\"document.location.href='"+link+"'\" value=\"Reset statistic\" />";
	}

	public void setUserFilesTable(String[] filePaths, String[] visits) {
		this.userFilesTable = "<table border='1'>"+
		"<tr>"+
		"	<td>File path</td>"+
		"	<td>Visits</td>"+
		"</tr>";
		
		for (int i = 0; i < filePaths.length; i++) {
			this.userFilesTable += "<tr>"+
			"	<td>"+filePaths[i]+"</td>"+
			"	<td>"+visits[i]+"</td>"+
			"</tr>";
		}
		
		this.userFilesTable += "<table>";
	}
    
    public String getInterfaceHtml() {
		String interfaceHtml = "<html>"+
		"<head>"+
		"	<title>Statistic</title>"+
		"</head>"+
		"<body>"+
		"	<p align='left'>"+
		"		Domain: <b>"+this.userDomain+"</b><br/>"+
		"		User name: <b>"+this.userName+"</b><br/>"+
		"		User surname: <b>"+this.userSurname+"</b><br/>"+
		"		Last visit: <b>"+this.lastLoginDate+"</b><br/>"+
		"		<br/>"+this.statsResetLink+"<br/>"+
		"	</p>"+
		"	<p align='center'>"+
		"		"+this.userFilesTable+
		"	</p>"+
		"</body>"+
		"</html>";
		
		return interfaceHtml;
	}
}